fix: 修复 upx 内核切换后首次启动重复下载内核的问题#1295
Closed
abcfy2 wants to merge 1 commit into
Closed
Conversation
core_check 的 upx 分支在第52行将内核文件移动到 $BINDIR/CrashCore.upx, 但符号链接 $TMPDIR/CrashCore 却指向了不存在的 $TMPDIR/CrashCore.upx, 导致链接悬空(目标文件实际位于 $BINDIR)。 在 BusyBox 路由器上(BINDIR=/jffs/ShellCrash ≠ TMPDIR=/tmp/ShellCrash), check_core 的自愈入口 core_find 会被绕过而无法修复该悬空链接: BusyBox find 不支持 -size(故 find_para 为空),且 `find <悬空链接>` 会把链接本身列为结果,使 `[ -z "$(...)" ]` 判定为假、core_find 被跳过; 随后 `[ ! -f $TMPDIR/CrashCore ]` 跟随悬空链接误判内核缺失,触发重复下载。 将符号链接改为指向 $BINDIR/CrashCore.upx,与文件实际位置一致。 该写法对 BINDIR==TMPDIR 的小闪存模式同样正确。 仅在 BusyBox 路由器上、切换 upx 内核后未重启即启动时可复现; GNU find 环境因 -size 过滤掉悬空链接会正常触发 core_find 自愈,故此前未被发现。
ashi009
added a commit
to ashi009/ShellCrash
that referenced
this pull request
Jul 11, 2026
On OpenWrt $TMPDIR is tmpfs (RAM) and $BINDIR sits on a transparently-compressed fs (squashfs/ubifs). Unpacking the core to $TMPDIR pins the whole ~40MB binary in unreclaimable Shmem, and a compressed copy is still kept on rom - paying twice. When $TMPDIR is tmpfs and $BINDIR is squashfs/ubifs/overlay, store the verified naked binary as $BINDIR/CrashCore.raw and symlink $TMPDIR/CrashCore to it, dropping the downloaded archive. The binary is transparently compressed on rom (~2.2:1, comparable to keeping .gz) and its text/rodata become file-backed and reclaimable at runtime (RssShmem 0). Other filesystems keep the existing behavior. The upx branch's symlink target is also corrected from $TMPDIR to $BINDIR (same dangling-symlink issue as juewuy#1295). For juewuy#1304
ashi009
added a commit
to ashi009/ShellCrash
that referenced
this pull request
Jul 11, 2026
Adds store_on_rom() helper (tmpfs $TMPDIR + squashfs/ubifs/overlay $BINDIR). On such devices core_webget no longer downloads the upx core (its stub decompresses into a memfd = RAM at runtime); it fetches the tar.gz instead and core_check stores the naked binary as $BINDIR/CrashCore.raw, symlinked from $TMPDIR. The binary is transparently compressed on rom and file-backed/reclaimable at runtime (RssShmem 0). Other filesystems and explicit upx keep prior behavior. Also corrects the upx branch symlink target $TMPDIR -> $BINDIR (same dangling-symlink issue as juewuy#1295). For juewuy#1304
ashi009
added a commit
to ashi009/ShellCrash
that referenced
this pull request
Jul 11, 2026
Replaces the binary compressed-rom check with store_raw_worth_it(), which decides per environment: store the naked binary on $BINDIR (0 RAM) only when $TMPDIR is tmpfs AND $BINDIR can hold it with margin (estimated ~2:1 on squashfs/ubifs, full size otherwise). Otherwise keep a compressed copy and decompress to tmp as before. core_webget skips the upx core when raw storage is viable, fetching tar.gz instead. Rationale (rough budgets for a ~40M core): raw on squashfs ~15M rom / 0 RAM; gz 10M rom / ~40M RAM; upx 9M rom / ~40M RAM (memfd). Raw wins when rom has room; compressed wins when rom is the scarce resource. Also corrects the upx branch symlink target $TMPDIR -> $BINDIR (juewuy#1295). For juewuy#1304
Contributor
Author
|
已由 #1305(core: 按环境权衡 rom/RAM 取舍决定内核存储形态)解决。该 PR 的三个 commit 均引用了本 PR,将 upx 分支软链目标从 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
切换到 upx 内核后第一次启动,会提示"未找到核心"然后重新下载一遍刚下好的内核。
原因:core_check 的 upx 分支把内核文件 mv 到了 $BINDIR/CrashCore.upx,但 $TMPDIR/CrashCore 这个符号链接指向的却是 $TMPDIR/CrashCore.upx(不存在),是个断链。BusyBox 路由器上 check_core 本来能靠 core_find 自愈重建链接,但 BusyBox 的 find 不支持 -size,还会把断链本身当成结果列出来,于是 core_find 被跳过、断链没修上,被判成内核缺失,触发重新下载。
把链接指向 $BINDIR/CrashCore.upx 即可。只有 upx 受影响,tar.gz / gz 都是直接放真实文件,没这个问题。